﻿#include <iostream>
#include"unique_ptr.h"
#include"shared_ptr.h"
#include"weak_ptr.h"
class Test {
public:
    ~Test() {
        std::cout << "~Test" << std::endl;
    }
};

void func() {
    weak_ptr<Test>wp1;
    weak_ptr<Test>wp2;
    {
        shared_ptr<Test>sp1(new Test());
        wp1 = sp1;
        shared_ptr<Test>sp2(new Test());
        wp2 = sp2;
        sp2 = sp1;
        std::cout << wp1.use_count() << std::endl;
        std::cout << wp2.use_count() << std::endl;
        shared_ptr<Test>sp = wp1.lock();
        std::cout << wp1.use_count() << std::endl;
    }
    shared_ptr<Test>sp = wp1.lock();
    std::cout << wp1.use_count() << std::endl;
}


int main()
{
    func();
    std::cout << "Hello World!\n";
}

